package com.madrivergroup.mamatodo.views;


import com.madrivergroup.mamatodo.tasks.Task;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;

public class TaskListItem extends LinearLayout {
	

	private Task task = null;
	private CheckedTextView check = null;
	
	public TaskListItem(Context context, AttributeSet attrs) {
		super(context, attrs);	
	}
	
	
	/* (non-Javadoc)
	 * @see android.view.View#onFinishInflate()
	 * Need to set the reference to the Checkbox after the View gets
	 * Inflated.  Cannot do this in the contructor like we did before
	 */
	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		check = (CheckedTextView)findViewById(android.R.id.text1);
	}
	
	public void setTask(Task task) {
		this.task = task;
		check.setText( task.getName() );
		check.setChecked( task.isComplete() );
	}
	public Task getTask() {
		return task;
	}
	
}
